VERSION 5.00
Object = "{76DA8CE9-E736-47FC-B43F-82650E2EFBAF}#1.0#0"; "oControls.ocx"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmMaintItem 
   BackColor       =   &H00FFFFFF&
   BorderStyle     =   0  'None
   Caption         =   "Item"
   ClientHeight    =   4275
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   9000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   ScaleHeight     =   4275
   ScaleWidth      =   9000
   ShowInTaskbar   =   0   'False
   Tag             =   "Application"
   Begin MSDataGridLib.DataGrid dtgDetails 
      Height          =   1875
      Left            =   0
      TabIndex        =   1
      Top             =   2040
      Width           =   8820
      _ExtentX        =   15558
      _ExtentY        =   3307
      _Version        =   393216
      AllowUpdate     =   -1  'True
      BackColor       =   16777215
      HeadLines       =   2
      RowHeight       =   15
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin oControls.oTab oTab2 
      Height          =   1995
      Left            =   0
      TabIndex        =   0
      Top             =   -15
      Width           =   8820
      _ExtentX        =   15558
      _ExtentY        =   3519
      TabCount        =   2
      TabCaption(0)   =   "            MAIN            "
      TabContCtrlCnt(0)=   7
      Tab(0)ContCtrlCap(1)=   "cbocUnit"
      Tab(0)ContCtrlCap(2)=   "txtcUnit"
      Tab(0)ContCtrlCap(3)=   "txtcItemNo"
      Tab(0)ContCtrlCap(4)=   "txtcDesc"
      Tab(0)ContCtrlCap(5)=   "cbocType"
      Tab(0)ContCtrlCap(6)=   "txtcType"
      Tab(0)ContCtrlCap(7)=   "frmContainer"
      TabCaption(1)   =   "            LIST            "
      TabContCtrlCnt(1)=   2
      Tab(1)ContCtrlCap(1)=   "dtgList"
      Tab(1)ContCtrlCap(2)=   "oFrames2"
      TabStyle        =   1
      TabTheme        =   1
      ActiveTabBackStartColor=   16514555
      ActiveTabBackEndColor=   16514555
      InActiveTabBackStartColor=   16777215
      InActiveTabBackEndColor=   15397104
      BeginProperty ActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty InActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      OuterBorderColor=   10198161
      DisabledTabBackColor=   -2147483633
      DisabledTabForeColor=   10526880
      Begin VB.ComboBox cbocUnit 
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   6.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   1740
         Style           =   2  'Dropdown List
         TabIndex        =   8
         Top             =   1500
         Width           =   1590
      End
      Begin oControls.oTextBox txtcUnit 
         Height          =   285
         Left            =   210
         TabIndex        =   7
         Top             =   1500
         Width           =   3090
         _ExtentX        =   5239
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Label           =   "Unit"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   1530
      End
      Begin oControls.oTextBox txtcItemNo 
         Height          =   285
         Left            =   210
         TabIndex        =   6
         Tag             =   "1"
         Top             =   825
         Width           =   3090
         _ExtentX        =   5239
         _ExtentY        =   503
         BackColor       =   14745599
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         AllCaps         =   -1  'True
         Mandatory       =   -1  'True
         Label           =   "Item No."
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   1530
      End
      Begin oControls.oTextBox txtcDesc 
         Height          =   285
         Left            =   210
         TabIndex        =   5
         Top             =   1155
         Width           =   8370
         _ExtentX        =   14552
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Label           =   "Description"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   6810
      End
      Begin VB.ComboBox cbocType 
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   6.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   6855
         Style           =   2  'Dropdown List
         TabIndex        =   3
         Top             =   825
         Width           =   1755
      End
      Begin MSDataGridLib.DataGrid dtgList 
         Height          =   1275
         Left            =   -75000
         TabIndex        =   2
         Tag             =   "."
         Top             =   720
         Width           =   8820
         _ExtentX        =   15558
         _ExtentY        =   2249
         _Version        =   393216
         AllowUpdate     =   0   'False
         BackColor       =   16777215
         HeadLines       =   1
         RowHeight       =   15
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ColumnCount     =   2
         BeginProperty Column00 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         BeginProperty Column01 
            DataField       =   ""
            Caption         =   ""
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
               Type            =   0
               Format          =   ""
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   1033
               SubFormatType   =   0
            EndProperty
         EndProperty
         SplitCount      =   1
         BeginProperty Split0 
            BeginProperty Column00 
            EndProperty
            BeginProperty Column01 
            EndProperty
         EndProperty
      End
      Begin oControls.oFrames oFrames2 
         Height          =   1695
         Left            =   -75000
         Top             =   300
         Width           =   8820
         _ExtentX        =   15558
         _ExtentY        =   2990
         FrameColor      =   16777215
         FillColor       =   16640737
         RoundedCorner   =   0   'False
         Caption         =   "List of Items"
         Alignment       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Picture         =   "frmMaintItem.frx":0000
      End
      Begin oControls.oTextBox txtcType 
         Height          =   285
         Left            =   5490
         TabIndex        =   4
         Top             =   825
         Width           =   3090
         _ExtentX        =   5239
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Label           =   "Type"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   1530
      End
      Begin oControls.oFrames frmContainer 
         Height          =   1695
         Left            =   0
         Top             =   300
         Width           =   8820
         _ExtentX        =   15558
         _ExtentY        =   2990
         FrameColor      =   16777215
         FillColor       =   16777215
         RoundedCorner   =   0   'False
         Caption         =   "Information"
         Alignment       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Picture         =   "frmMaintItem.frx":0A12
      End
   End
End
Attribute VB_Name = "frmMaintItem"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'----------------------------------------------------------------------------------------------------------------------------------
'Standard Programming Format----------------------------------------------------------------------------------------
'----------------------------------------------------------------------------------------------------------------------------------

Dim cnHeader As New Connection
'Dim cnDetail As New Connection
Dim rsHeader As New Recordset
'Dim rsDetail As New Recordset
Dim tmpObj As Object

Dim sBit() As Boolean
Dim vBookmark As Variant

Public mode As eMode

Private Sub DataOtherBind()
'    Set dtgList.DataSource = rsHeader
End Sub

Public Sub TBNew()
    mode = AddEditNew
    
    If rsHeader.State <> 1 Then
        TranConnect cnHeader
'        TranConnect cnDetail
        TranRecordset Mid$(Me.Name, 4, Len(Me.Name)), rsHeader, cnHeader, "1=0"
'        TranRecordset Mid$(Me.Name, 4, Len(Me.Name)) & "_D", rsDetail, cnDetail
        
        DataSourceBind rsHeader, Me
'        DataFieldBind rsHeader, Me
        DataOtherBind
    Else
        vBookmark = rsHeader.Bookmark
    End If
    
    ControlObjects Me
    BitEnable sBit, Me, oMDI
    
    rsHeader.AddNew
'    rsHeader!cCompID = sCompanyID
'    rsHeader!dDate = Now
'    rsHeader!cTranNo = GenAutoNum(Mid$(Me.Name, 4, Len(Me.Name)), cbocType.Text)
    
'    FilterRecord "cTranNo", rsHeader!cTranNo, rsDetail
    
    RSDisconnectCN rsHeader
'    RSDisconnectCN rsDetail
    
End Sub

Public Sub TBEdit()
    mode = AddEditNew
    
    ControlObjects Me
'    FilterRecord "cTranNo", rsHeader!cTranNo, rsDetail
    
    RSDisconnectCN rsHeader
'    RSDisconnectCN rsDetail
    
    BitEnable sBit, Me, oMDI
End Sub

Public Sub TBDelete()
    On Error GoTo ErrHandler
    
    Dim sID As String
    
    RSConnectCN rsHeader, cnHeader
'    RSConnectCN rsDetail, cnDetail
    
    sID = rsHeader!cTranNo
    
    If MsgBox("Are you sure you want to delete this record?", vbQuestion + vbYesNo, ProjectVersion) = vbNo Then Exit Sub
'    FilterRecord "cTranNo", rsHeader!cTranNo, rsDetail
'    If rsDetail.RecordCount <> 0 Then
'        rsDetail.MoveFirst
'        Do Until rsDetail.RecordCount = 0
'            rsDetail.Delete adAffectCurrent
'            If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
'        Loop
'    End If
    
    AuditLog Mid$(Me.Name, 4, Len(Me.Name)), Trim(txtcItemNo), "Deleted"
    rsHeader.Delete adAffectCurrent
    
    'rsDetail.UpdateBatch adAffectAll
    rsHeader.UpdateBatch adAffectAll
    
    TBPrevious
    mode = Normal
    
    If rsHeader.RecordCount = 0 Then
        ClearDataValue Me
    Else
        vBookmark = rsHeader.Bookmark
        DataUnbind Me
        DataSourceBind rsHeader, Me
        DataFieldBind rsHeader, Me
        rsHeader.Bookmark = vBookmark
    End If
    
    BitEnable sBit, Me, oMDI

ErrHandler:
    If Err.Number = -2147217885 Then
        Resume Next
    ElseIf Err.Number = -2147217864 Or Err.Number = -2147217887 Then
        cn.Execute "DELETE " & Mid$(Me.Name, 4, Len(Me.Name)) & "_D WHERE cTranNo = '" & sID & "' AND cCompID = '" & sCompanyID & "'"
        'cn.Execute "DELETE " & Mid$(Me.Name, 4, Len(Me.Name)) & " WHERE cTranNo = '" & sID & "' AND cCompID = '" & sCompanyID & "'"
        Resume Next
    End If

End Sub

Public Sub TBSave()
    On Error GoTo ErrHandler
    Dim lNew As Boolean
    
    mode = Find
    If rsHeader.Status = adRecNew Then lNew = True
    If MandatoryOK(Me) = False Then Exit Sub
    
    RSConnectCN rsHeader, cnHeader
    'RSConnectCN rsDetail, cnDetail

    cn.BeginTrans
    cnHeader.BeginTrans
    'cnDetail.BeginTrans
    
    rsHeader.UpdateBatch adAffectAll
    'rsDetail.UpdateBatch adAffectAll
   
    cn.CommitTrans
    cnHeader.CommitTrans
    'cnDetail.CommitTrans
    
    Set FrmName = Me
    mode = Normal
    ControlObjects Me
    
    AuditLog Mid$(Me.Name, 4, Len(Me.Name)), rsHeader!cTranNo, IIf(lNew, "Add Record", "Modify Record")
    MsgBox "Record/s successfully saved.", vbInformation, ProjectVersion
    
    BitEnable sBit, Me, oMDI
ErrHandler:
    If Err.Number = -2147168237 Then
        rsHeader.CancelBatch adAffectCurrent
        'If rsDetail.RecordCount <> 0 Then rsDetail.CancelBatch adAffectCurrent
        cnHeader.RollbackTrans
        'cnDetail.RollbackTrans
    ElseIf Err.Number <> 0 Then
        MsgBox Err.Description, vbCritical, ProjectVersion
    End If
End Sub

Public Sub TBUndo()
    mode = Normal
    
    'FilterRecord "cTranNo", rsHeader!cTranNo, rsDetail
    If rsHeader.Status = adRecNew Then
        'rsDetail.CancelBatch adAffectAll
        rsHeader.CancelUpdate
    Else
        rsHeader.CancelBatch adAffectCurrent
        'rsDetail.CancelBatch adAffectAll
    End If
        
    DataUnbind Me
    If rsHeader.RecordCount = 0 Then
        ClearDataValue Me
        rsHeader.Close
        'rsDetail.Close
        mode = Find
    Else
        rsHeader.Bookmark = vBookmark
        DataSourceBind rsHeader, Me
        DataFieldBind rsHeader, Me
        DataOtherBind
    End If
    
    ControlObjects Me
    BitEnable sBit, Me, oMDI
End Sub

Public Sub TBFind()
    Dim sCond As String
    
    If mode = Find Then
        mode = Normal
        
        sCond = GetSearchString(Me)
        TranConnect cnHeader
        'TranConnect cnDetail
        TranRecordset Mid$(Me.Name, 4, Len(Me.Name)), rsHeader, cnHeader, sCond
        'TranRecordset Mid$(Me.Name, 4, Len(Me.Name)) & "_D", rsDetail, cnDetail, IIf(sCond <> "", " cTranNo in (SELECT cTranNo FROM " & Mid$(Me.Name, 4, Len(Me.Name)) & " WHERE " & sCond & ")", "")
        'FilterRecord "cTranNo", rsHeader!cTranNo, rsDetail
        
        DataSourceBind rsHeader, Me
        DataFieldBind rsHeader, Me
        DataOtherBind
        
        RSDisconnectCN rsHeader
        'RSDisconnectCN rsDetail
               
    Else
        mode = Find
        rsHeader.Close
        'rsDetail.Close
        DataUnbind Me
        ClearDataValue Me
    End If
    
    ControlObjects Me
    BitEnable sBit, Me, oMDI
End Sub

Public Sub TBPrint()
    PrintReceipt Mid$(Me.Name, 4, Len(Me.Name)), rsHeader!cTranNo
End Sub

Public Sub TBFirst()
    FirstRecord rsHeader
End Sub

Public Sub TBPrevious()
    PreviousRecord rsHeader
End Sub

Public Sub TBNext()
    NextRecord rsHeader
End Sub

Public Sub TBLast()
    LastRecord rsHeader
End Sub

Public Sub TBNewLine()
    
End Sub

Public Sub TBDeleteLine()

End Sub

Public Sub TBApprove()

End Sub

Public Sub TBReject()

End Sub

Public Sub TBUntag()

End Sub

Public Sub TBClose()
    On Error Resume Next
    Set FrmName = Nothing
    Unload Me
End Sub

Public Sub TBReload()
    Me.ZOrder
    Set FrmName = Me
    BitEnable sBit, Me, oMDI
End Sub

Private Sub dtgDetails_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If mode <> AddEditNew Then Exit Sub
    If Button = 2 Then
        PopupMenu oMDI.mnuPopupDetail
    End If
End Sub

Private Sub Form_Click()
    TBReload
End Sub

Private Sub Form_Load()
    GetAccessLevel oMDI.tbMain, sUserRole, Me.Name, sBit()
    mode = Find
      
    ApplyFrameTheme frmContainer, Me
    BitEnable sBit, Me, oMDI
End Sub
 


